package com.bang.study.jvm.oom;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: Bang
 * @Date: 2019/9/28 11:17
 * @Description: 模拟java堆溢出
 * Vm参数: -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError
 */
public class HeapOom {

    static class OomObject {

    }

    public static void main(String[] args) throws InterruptedException {
        // 睡20s 方便观测GC信息
        Thread.sleep(1000*20);
        List<Object> list = new ArrayList<Object>();
        while (true) {
            list.add(new OomObject());
        }
    }
}
